import Buff from '@/Buff';
import BuffUtil from '@/BuffUtil';
import SelectUtil from '@/SelectUtil';
import BuffCommon from 'code/Core/Common/BuffCommon';
import EffectCommon from 'code/Core/Common/EffectCommon';
import MovementCommon from 'code/Core/Common/MovementCommon';
import UnitCommon from 'code/Core/Common/UnitCommon';
import AbilityBase from 'code/Scripts/Abilities/base/AbilityBase';
/**
 * 缠绕之种
 */
export default class DLY_SeedOfEntang extends AbilityBase {
    static instance: DLY_SeedOfEntang;
    buffType: AppBuffType = {
        id: 'buff_DLY_SeedOfEntang',
        art: this.art,
        name: this.abilityName,
        ubertip: '被缠绕，无法移动，并且持续onTakeDamage',
        dur: 4,
        targetArt: 'Abilities\\Spells\\NightElf\\EntanglingRoots\\EntanglingRootsTarget.mdl',
        targetAttach: 'origin',
        attribute: {
            move_speed: -1000,
        },
        interval: 1,
        onInterval: this.onBuffInterl.bind(this),
    };
    onReach(p: 定点限高投射物参数) {
        EffectCommon.addEffectAndDeleyRemove('Seed\\Seed Squirt Classic\\Seed Squirt Classic.mdx', p.curX, p.curY, 1);
        let es = SelectUtil.getEnemyUnitsInRange(p.caster, 225, p.curX, p.curY);
        for (let e of es) {
            // BuffUtil.addBuff(e, this.buffType.id, p.caster);
            BuffCommon.addBuff({
                target: e,
                caster: p.caster,
                buffTypeId: this.buffType.id,
                ablityId: this.id,
            });
        }
    }
    onBuffInterl(buff: Buff) {
        let s = buff.getCaster();
        let lv = this.getAbilityLevel(s);
        let dmg = 20 * lv + UnitCommon.取法强(s) * (0.6 + 0.2 * lv);
        DamageSystemInstance.applyPoisionDamage(buff.getParent(), s, dmg, this.id, true);
    }
    constructor(id: string) {
        super(id);
        DLY_SeedOfEntang.instance = this;
        this.init();
        se.onUnitSpellEffect(this.onSpellEffect.bind(this), this.id);
    }
    init() {
        BuffUtil.registerBuffType(this.buffType);
    }
    cast<T extends Object = any>(tarX: number, tarY: number, source: unit, target: unit, data?: T): void {
        MovementCommon.定点限高投射物({
            tarX: tarX,
            tarY: tarY,
            missile: 'Seed\\Seed Shot.mdx',
            caster: source,
            speed: 400,
            maxHeight: 400,
            onReachTarget: this.onReach.bind(this),
        });
    }
    onSpellEffect() {
        this.cast(GetSpellTargetX(), GetSpellTargetY(), GetTriggerUnit(), GetSpellTargetUnit());
    }
}
